#include <iostream>
#include <fstream>
#include<string>
#include<cstring>
using namespace std;

#define STDIN
//#define DEBUG
#define SIZE 100

int t;
int C[SIZE+1][SIZE+1];
int A[SIZE+1][SIZE+1];

enum COLOR {WHITE = 0, BLACK = 1};

int lowbit(int t) {
    return (t ^ (t-1)) & t;
}

void Modify(int x, int y, int delta)
{
    for(int i = x; i <= SIZE; i += lowbit(i))
        for(int j = y; j <= SIZE; j += lowbit(j))
            C[i][j] += delta;
}

int Sum(int i, int j)
{
    int result = 0;
    for(int x = i; x > 0; x -= lowbit(x))
    {
        for(int y = j; y > 0; y -= lowbit(y))
        {
            result += C[x][y];
        }
    }

    return result;
}

void UpdateWhite(int x, int y, int L) {
    for (int i = x; i <= x+L-1; ++i) {
        for (int j = y; j <= y+L-1; ++j) {
            {
                if (A[i][j] == 0)
                    continue;
                else
                    Modify(i, j, -1);
                A[i][j] = 0;
            }
        }
    }
}

void UpdateBlack(int x, int y, int L) {
    for (int i = x; i <= x+L-1; ++i) {
        for (int j = y; j <= y+L-1; ++j) {
            {
                if (A[i][j] == 1)
                    continue;
                else
                    Modify(i, j, 1);
                A[i][j] = 1;
            }
        }
    }
}
int Test(int x, int y, int L) {
    return Sum(x+L-1,y+L-1)+Sum(x-1,y-1)-Sum(x-1,y+L-1)-Sum(x+L-1,y-1);
}

int main() {
#if defined(STDIN)
    fstream cin("bin/1656.in");
#endif

    memset(C, 0, sizeof(C));
    memset(A, 0, sizeof(A));

    int t;
    string command;
    int x, y, L;

    cin >> t;
    while(t--) {
        cin >> command >> x >> y >> L;
#if defined(DEBUG)
        cout << command << "\t" << x << "\t" << y << endl;
#endif
        switch(command[0]) {
            case 'W':
                UpdateWhite(x, y, L);
                break;
            case 'B':
                UpdateBlack(x, y, L);
                break;
            case 'T':
                cout << Test(x, y, L) << endl;
                break;
        }
#if defined(DEBUG)
        for (int i = 1; i <= SIZE; ++i) {
            for (int j = 1; j <= SIZE; ++j)
                cout << C[i][j] << " ";
            cout << endl;
        }
#endif
    }
    return 0;
}
